package com.fitz.remote.handler;

import com.fitz.invoke.RpcInvoker;
import com.fitz.remote.model.RpcResponse;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * @author fitz 2020-5-14 15:17
 */

public class RpcClientHandler extends SimpleChannelInboundHandler<RpcResponse> {

    private static final Logger logger = LoggerFactory.getLogger(RpcClientHandler.class);

    @Override
    protected void channelRead0(ChannelHandlerContext ctx, RpcResponse msg) throws Exception {
        RpcInvoker.getInstance().notifyCallback(msg.getRequestId(),msg);
        logger.info("consumer receive :{}",msg.toString());
    }
}
